Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • outfile txt | prevent wordwap

    Hello all,

    I need to export a txt file with single lines of karyotype without any wordwrap or enclosing quotes per observation for the txt file to work for ingestion by R. Stata 17 is not allowing me to using a couple of options below. Would appreciate any help figuring this out.
    P.S.: I deleted obs 95-100 in -dataex- since they were empty.

    outfile kar using ".\karyoingest.txt", noquote replace wide runtogether

    option noquote not allowed
    r(198);


    And this
    outfile v1 using "D:\gvenkataraman\Documents\Dropbox\Girish Files\Rotation_Harini\karycytobatch.txt", noquote replace wide

    exports a text file but the file still has wrapped lines. Unless I am not seeing this correctly in notepad.


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str241 kar
    "46,XX[1]/47~50,XX,t(3;3)(p2?1;q2?1),del(4)(q21q35),add(5)(q31),-7,add(8)(p21),add(9)(
    p13),der(11)t(7;11)(p13;p15)add(11)(q25),der(12)t(?5;12)(q31;q22),i(13)(q10),
    +16,add(16)(q11.2),der(16)t(9;16)(q12;q13),-17,add(22)(q13),+3-5mar,inc[cp19]"
    "46,XY[1]/45,XY,add(1)(p36.3),del(5)(q15q33),add(6)(p21),del(7)(q22q34),der(12)t(12;?14)(q15;q11.2),-14,add(17)(q21),add(20)(q11.2)[3]/46,XY,+1,der(1)t(1;?22)(q21;q11.2),del(5)(q15q33),del(7)(q22q34),add(17)(q21),add(20)(q11.2),-22[17]"      
    "46,XY[2]/45,XY,del(2)(p13p23),del(5)(q12q31.3),+8,del(9)(p21p24),der(11)t(11;11)(p13;
    q21),der(14)t(11;14)(q13;p11.1),-16,add(18)(q21.3),-20[14]/45,idem,add(22)(q11.2)[2]"                                                                      
    "46,XX[7]/45,XX,del(5)(q11.2q35),t(5;12)(p13;p11.2),r(7)(p22q11.2),-17[10]/90,idemx2[cp3]"                                                                                                                                                        
    "67-82,XXYY,-3,add(5)(q22),-6,-7,-9,-10,-12,-12,der(14)t(3;14)(q21;q32),-16,-16,-17,idic(22)(p11.2),+mar[cp6]"                                                                                                                                                                                                                                                                                                                                                                        
    end
    Last edited by Girish Venkataraman; 09 Jan 2023, 16:03. Reason: Forgot to mention second part of my efforts after exporting a file successfully.

  • #2
    Unfortunately, somehow your dataex output was wrapped onto multiple lines. Here is a corrected version, unwrapped so that each observation starts and ends with a quotation mark.
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str241 kar
    "46,XX[1]/47~50,XX,t(3;3)(p2?1;q2?1),del(4)(q21q35),add(5)(q31),-7,add(8)(p21),add(9)(p13),der(11)t(7;11)(p13;p15)add(11)(q25),der(12)t(?5;12)(q31;q22),i(13)(q10),+16,add(16)(q11.2),der(16)t(9;16)(q12;q13),-17,add(22)(q13),+3-5mar,inc[cp19]"
    "46,XY[1]/45,XY,add(1)(p36.3),del(5)(q15q33),add(6)(p21),del(7)(q22q34),der(12)t(12;?14)(q15;q11.2),-14,add(17)(q21),add(20)(q11.2)[3]/46,XY,+1,der(1)t(1;?22)(q21;q11.2),del(5)(q15q33),del(7)(q22q34),add(17)(q21),add(20)(q11.2),-22[17]"      
    "46,XY[2]/45,XY,del(2)(p13p23),del(5)(q12q31.3),+8,del(9)(p21p24),der(11)t(11;11)(p13;q21),der(14)t(11;14)(q13;p11.1),-16,add(18)(q21.3),-20[14]/45,idem,add(22)(q11.2)[2]"                                                                      
    "46,XX[7]/45,XX,del(5)(q11.2q35),t(5;12)(p13;p11.2),r(7)(p22q11.2),-17[10]/90,idemx2[cp3]"                                                                                                                                                        
    "67-82,XXYY,-3,add(5)(q22),-6,-7,-9,-10,-12,-12,der(14)t(3;14)(q21;q32),-16,-16,-17,idic(22)(p11.2),+mar[cp6]"                                                                                                                                                                                                                                                                                                                                                                        
    end
    Since you are only outputting a single string variable, the runtogether option is unhelpful - and it precludes the noquotes and wide options, hence the error messages. Perhaps this is what you seek.
    Code:
    . outfile kar using "~/Downloads/kar.txt", noquote replace wide 
    
    . type "~/Downloads/kar.txt"
    46,XX[1]/47~50,XX,t(3;3)(p2?1;q2?1),del(4)(q21q35),add(5)(q31),-7,add(8)(p21),add(9)(p13),der(11)t(7;11)(p13;p15)add(11)(q25),der(12)t(?5;12)(q31;q22),i(13)(q10),+16,add(16)(q11.2),der(16)t(9;16)(q12;q13),-17,add(22)(q13),+3-5mar,inc[cp19]    
    46,XY[1]/45,XY,add(1)(p36.3),del(5)(q15q33),add(6)(p21),del(7)(q22q34),der(12)t(12;?14)(q15;q11.2),-14,add(17)(q21),add(20)(q11.2)[3]/46,XY,+1,der(1)t(1;?22)(q21;q11.2),del(5)(q15q33),del(7)(q22q34),add(17)(q21),add(20)(q11.2),-22[17]         
    46,XY[2]/45,XY,del(2)(p13p23),del(5)(q12q31.3),+8,del(9)(p21p24),der(11)t(11;11)(p13;q21),der(14)t(11;14)(q13;p11.1),-16,add(18)(q21.3),-20[14]/45,idem,add(22)(q11.2)[2]                                                                          
    46,XX[7]/45,XX,del(5)(q11.2q35),t(5;12)(p13;p11.2),r(7)(p22q11.2),-17[10]/90,idemx2[cp3]                                                                                                                                                           
    67-82,XXYY,-3,add(5)(q22),-6,-7,-9,-10,-12,-12,der(14)t(3;14)(q21;q32),-16,-16,-17,idic(22)(p11.2),+mar[cp6]                                                                                                                                       
    
    .

    Comment


    • #3
      Originally posted by William Lisowski View Post
      Unfortunately, somehow your dataex output was wrapped onto multiple lines. Here is a corrected version, unwrapped so that each observation starts and ends with a quotation mark.
      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input str241 kar
      "46,XX[1]/47~50,XX,t(3;3)(p2?1;q2?1),del(4)(q21q35),add(5)(q31),-7,add(8)(p21),add(9)(p13),der(11)t(7;11)(p13;p15)add(11)(q25),der(12)t(?5;12)(q31;q22),i(13)(q10),+16,add(16)(q11.2),der(16)t(9;16)(q12;q13),-17,add(22)(q13),+3-5mar,inc[cp19]"
      "46,XY[1]/45,XY,add(1)(p36.3),del(5)(q15q33),add(6)(p21),del(7)(q22q34),der(12)t(12;?14)(q15;q11.2),-14,add(17)(q21),add(20)(q11.2)[3]/46,XY,+1,der(1)t(1;?22)(q21;q11.2),del(5)(q15q33),del(7)(q22q34),add(17)(q21),add(20)(q11.2),-22[17]"
      "46,XY[2]/45,XY,del(2)(p13p23),del(5)(q12q31.3),+8,del(9)(p21p24),der(11)t(11;11)(p13;q21),der(14)t(11;14)(q13;p11.1),-16,add(18)(q21.3),-20[14]/45,idem,add(22)(q11.2)[2]"
      "46,XX[7]/45,XX,del(5)(q11.2q35),t(5;12)(p13;p11.2),r(7)(p22q11.2),-17[10]/90,idemx2[cp3]"
      "67-82,XXYY,-3,add(5)(q22),-6,-7,-9,-10,-12,-12,der(14)t(3;14)(q21;q32),-16,-16,-17,idic(22)(p11.2),+mar[cp6]"
      end
      Since you are only outputting a single string variable, the runtogether option is unhelpful - and it precludes the noquotes and wide options, hence the error messages. Perhaps this is what you seek.
      Code:
      . outfile kar using "~/Downloads/kar.txt", noquote replace wide
      
      . type "~/Downloads/kar.txt"
      46,XX[1]/47~50,XX,t(3;3)(p2?1;q2?1),del(4)(q21q35),add(5)(q31),-7,add(8)(p21),add(9)(p13),der(11)t(7;11)(p13;p15)add(11)(q25),der(12)t(?5;12)(q31;q22),i(13)(q10),+16,add(16)(q11.2),der(16)t(9;16)(q12;q13),-17,add(22)(q13),+3-5mar,inc[cp19]
      46,XY[1]/45,XY,add(1)(p36.3),del(5)(q15q33),add(6)(p21),del(7)(q22q34),der(12)t(12;?14)(q15;q11.2),-14,add(17)(q21),add(20)(q11.2)[3]/46,XY,+1,der(1)t(1;?22)(q21;q11.2),del(5)(q15q33),del(7)(q22q34),add(17)(q21),add(20)(q11.2),-22[17]
      46,XY[2]/45,XY,del(2)(p13p23),del(5)(q12q31.3),+8,del(9)(p21p24),der(11)t(11;11)(p13;q21),der(14)t(11;14)(q13;p11.1),-16,add(18)(q21.3),-20[14]/45,idem,add(22)(q11.2)[2]
      46,XX[7]/45,XX,del(5)(q11.2q35),t(5;12)(p13;p11.2),r(7)(p22q11.2),-17[10]/90,idemx2[cp3]
      67-82,XXYY,-3,add(5)(q22),-6,-7,-9,-10,-12,-12,der(14)t(3;14)(q21;q32),-16,-16,-17,idic(22)(p11.2),+mar[cp6]
      
      .
      Thanks William. But I did what you mentioned in the second portion of #1. It exports a txt file all right without quotes. But when I open Notepad and check, there are still some entries which appear wrapped despite the Wordwrap option being turned off in notepad. Perhaps this is more of a notepad issue rather than a Stata issue? Strangely -dataex- and -outfile- seem to autowrap lines exactly at the same places. For now, I am just surgically fixing the notepad txt file with single lines per observation since its only 130 observations or so.

      Comment


      • #4
        Your problem is with Notepad. The type command confirms that precisely 5 lines were written to the output file. If you were to open the output file in Stata's Do-file editor window, you would view five lines that are not wrapped.

        I use a Macintosh, and I do not use the Mac equivalent of Notepad (TextEdit) for anything serious. A program, a dataset - these are not notes, and you need an editor that you can count on to render files faithfully.

        Perhaps a Windows user here will recommend a suitable text editor for your purposes. Notepad is not.

        I am just surgically fixing the notepad txt file with single lines per observation since its only 130 observations or so.
        What a poor idea. I do not even understand why you read the outfile output into Notepad if the objective is to have R read the data. For that matter, I don't understand why you apparently are reading dataex outpuit into Notepad.

        Is this what you have to do to move text from a restricted processing environment to a system with access to the web? If so, you definitely need to remove Notepad from your workflow. A workaround using the Do-file editor may be sufficient for your purposes.

        Comment


        • #5
          Originally posted by William Lisowski View Post
          Your problem is with Notepad. The type command confirms that precisely 5 lines were written to the output file. If you were to open the output file in Stata's Do-file editor window, you would view five lines that are not wrapped.

          I use a Macintosh, and I do not use the Mac equivalent of Notepad (TextEdit) for anything serious. A program, a dataset - these are not notes, and you need an editor that you can count on to render files faithfully.

          Perhaps a Windows user here will recommend a suitable text editor for your purposes. Notepad is not.



          What a poor idea. I do not even understand why you read the outfile output into Notepad if the objective is to have R read the data. For that matter, I don't understand why you apparently are reading dataex outpuit into Notepad.

          Is this what you have to do to move text from a restricted processing environment to a system with access to the web? If so, you definitely need to remove Notepad from your workflow. A workaround using the Do-file editor may be sufficient for your purposes.
          Thank again. The R library I need will take only a txt file with single line data. There are libraries to import Stata files into R directly but my specific R package will not accept input data frames like that. And no, I was not reading -dataex- into notepad. I was only remarking that notepad and -dataex- (when pasted into this statalist post submission) coincidentally automatically wrap the first entry at the exact same string position. Will look into non-notepad options.

          Comment

          Working...
          X